package com.silverbox.waimai.dubboApi.order;

import java.util.List;
import java.util.Map;

import com.silverbox.shopper.entity.ThirdUserInfo;
import com.silverbox.sweeporder.controller.index.vo.ShopperConfigExtend;
import com.silverbox.sweeporder.controller.waimai.entryvo.CouponBaseDto;
import com.silverbox.sweeporder.controller.waimai.entryvo.CreateWaimaiEntryDto;
import com.silverbox.waimai.entity.*;
import com.silverbox.waimai.entity.extend.*;

/**
 * @Title:OrderServiceApi
 * @Description: 订单接口
 * @author CAOXJ
 * @date 2017年12月22日 上午11:32:27
 */
public interface WaimaiServiceApi {

    /**
     * 根据订单号查询订单以及明细
     *
     * @param orderNum
     * @return
     */
    WaimaiExtend getWaimaiAndDetailByOrderNum(String orderNum);

    /**
     * 根据订单号获取订单
     *
     * @param orderNum
     * @return
     */
    Waimai getWaimaiByOrderNum(String orderNum);

    /**
     * 保存订单
     *
     * @return
     */
    void saveWaimai(WaimaiExtend waimai, ShopperConfigExtend shopperConfigExt, CreateWaimaiEntryDto createWaimaiEntryVO);

    /**
     * 更新订单
     *
     * @param waimai
     * @return
     */
    int updateWaimai(Waimai waimai);

    /**
     * 根据用户id获取订单
     *
     * @param waimaiParam
     * @return
     */
    Waimai getWaimaiByBuyerId(WaimaiParam waimaiParam);

    /**
     * 根据桌台号获取订单
     *
     * @param waimaiParam
     * @return
     */
    Waimai getWaimaiByTableNum(WaimaiParam waimaiParam);

    /**
     * 根据用户id获取预订单
     *
     * @param waimaiParam
     * @return
     */
    Waimai getPreparationWaimaiByBuyerId(WaimaiParam waimaiParam);

    /**
     * 根据桌台号获取预订单
     *
     * @param waimaiParam
     * @return
     */
    Waimai getPreparationWaimaiByTableNum(WaimaiParam waimaiParam);

    /**
     * 加菜
     *  @param waimai
     * @param oldItems
     * @param vouchers
     * @param memberId
     */
    void addDish(WaimaiExtend waimaiExtend, List<WaimaiItemExtend> oldItems, CreateWaimaiEntryDto createWaimaiEntryVO,ShopperConfigExtend shopperConfigExtend);

    /**
     * 根据用户id获取未完成订单
     *
     * @param waimaiParam
     * @return
     */
    Waimai getUnfinishWaimaiByBuyerId(WaimaiParam waimaiParam);

    /**
     * 根据桌台号获取未完成订单
     *
     * @param waimaiParam
     * @return
     */
    Waimai getUnfinishWaimaiByTableNum(WaimaiParam waimaiParam);

    /**
     * 根据用户id获取订单以及明细
     *
     * @param waimaiParam
     * @return
     */
    WaimaiExtend getWaimaiAndDetailByBuyerId(WaimaiParam waimaiParam);

    /**
     * 根据桌台号获取订单以及明细
     *
     * @param waimaiParam
     * @return
     */
    WaimaiExtend getWaimaiAndDetailByTableNum(WaimaiParam waimaiParam);

    /**
     * 根据桌台号和用户id获取订单以及明细
     *
     * @param waimaiParam
     * @return
     */
    WaimaiExtend getWaimaiAndDetailByTableNumAndBuyerId(WaimaiParam waimaiParam);

    /**
     * 获取历史订单以及明细
     *
     * @param storeId
     * @param buyerId
     * @param isFirst
     * @param pageCount
     * @param maxId
     * @return
     */
    List<WaimaiExtend> getHistoryWaimaiList(WaimaiParam param);

    /**
     * 根据订单编号查询支付宝待撤销订单记录
     *
     * @param orderNum
     * @return
     */
    List<WaimaiSerialnumber> getWaimaiSerialnumberByOrderNum(String orderNum);

    /**
     * 保存等待支付宝撤销订单记录
     *
     * @param waimaiSerialnumber
     * @return
     */
    int saveWaimaiSerialnumber(WaimaiSerialnumber record);

    /**
     * 根据第三方交易号删除撤单记录
     *
     * @param outTradeNo
     * @return
     */
    int deleteWaimaiSerialNumberByOutTradeNo(String outTradeNo);

    /**
     * 批量删除订单
     *
     * @param ids
     * @return
     */
    void deleteOrderByIds(List<String> ids);

    /**
     * 获取仿菜
     *
     * @param storeId
     * @param tableUid
     * @param stareDate
     * @param endDate
     * @return
     */
    List<CopyGoods> getCopyGoods(Integer storeId, String tableUid, String startDate, String endDate);

    /**
     * 上传订单
     *
     * @param string
     * @param orderNum
     * @param koubeiUploadUrl
     * @param uploadOrderFlag
     * @return void
     * @throws @author litao
     * @date 2018年1月11日
     */
    void uploadOrder(Waimai waimai, String orderNum, String koubeiUploadUrl, String uploadOrderFlag, Long OuterSupportId);

    /**
     * 推送支付宝生活号消息
     *
     * @param waimai
     * @param alipayUserId
     * @param nick
     * @param address
     * @param msgType
     */
    void sendServiceWindowMsg(Waimai waimai, String alipayUserId, String nick, String address, String sweepUrl,
                              String serviceWindowUrl, String msgType);

    /**
     * 根据订单号批量删除订单
     *
     * @param orderNum
     * @return
     */
    void deleteOrderByOrderNum(List<String> orderNum);

    /**
     * 根据订单条件修改订单
     *
     * @param waimai
     */
    int updateWaimaiByCleanTable(WaimaiParam waimai);

    /**
     * 获取已点过的菜
     *
     * @param storeId
     * @param buyerId
     * @param createDate
     * @return
     */
    List<AlreadyGoods> getAlreadyGoods(Integer storeId, Long thirdUserInfoId, String createDate);

    /**
     * 获取在线订单未核销订单
     *
     * @param param
     * @return
     */
    List<WaimaiExtend> getOnlineOrderHexiao(WaimaiParam param);

    /**
     * 获取在线订单取餐柜订单
     *
     * @param param
     * @return
     */
    List<WaimaiExtend> getOnlineMealOrder(WaimaiParam param);

    /**
     * 批量更新订单信息
     *
     * @param param
     */
    int updateWaimaiIdOrNum(WaimaiParam param);

    /**
     * 创建修改订单操作相关时间
     *
     * @param timeRelated
     */
    int saveAndUpdateWaimaiTimeRelated(WaimaiTimeRelated timeRelated);

    /**
     * 根据订单号修改订单信息
     *
     * @param param
     * @return
     */
    int updateWaimaiByOrderNum(Waimai param);

    /**
     * 保存或修改订单批次信息
     *
     * @param waimaiBath
     * @return
     */
    int saveOrUpdateWaimaiBath(WaimaiBath waimaiBath);

    /**
     * 保存订单超时记录表
     *
     * @param receiptWaimai
     * @return
     */
    int saveReceiptTimeoutWaimai(ReceiptTimeoutWaimai receiptWaimai);

    /**
     * 查询订单超时记录表数据根据订单号查询
     *
     * @param orderNum
     * @return
     */
    ReceiptTimeoutWaimai getReceiptTimeoutWaimai(String orderNum);

    /**
     * 根据取餐码获取订单信息
     *
     * @param param
     * @return
     */
    WaimaiExtend getwaimaiBytakeMealCode(WaimaiParam param);

    /**
     * 保存订单操作关联表
     *
     * @param waimaiOperateRelated
     * @return
     */
    int saveWaimaiOperateRelated(WaimaiOperateRelated waimaiOperateRelated);

    /**
     * 获取当天在线订单未核销预约订单
     *
     * @param param
     * @return
     */
    List<WaimaiExtend> getTodayOrderHexiaoOrDelivery(WaimaiParam param);

    List<Waimai> getMyUnPayOrder(Integer storeId, String tableName, String buyerId);

    void deleteUnpayHistoryOrderById(Long id);

    /**
     * 保存下单消息
     *
     * @param msgRecord
     * @return
     */
    int saveMsgRecord(MsgRecord msgRecord);

    /**
     * 根据店铺Id和机器号Id去获取消息记录
     *
     * @return
     */
    List<MsgRecord> selectMsgRecord(Integer storeId, Long machineId);

    /**
     * 根据msgCode删除消息记录
     *
     * @param msgCode
     */
    void deleteMsgRecord(String msgCode);

    Map<String,Object> findAllOrdersByShop(Long shopId, String shopName, Integer outSupportId, Integer pageNo, Integer pageSize, List<String> buyerId);

    void saveWaimaiOperateRelated(Waimai waimai, ThirdUserInfo thirdUserInfo, String value);

    WaimaiExtend calcPromotionPrice(List<WaimaiItemExtend> waimaiItems, WaimaiExtend waimai, CouponBaseDto couponBaseDto,ShopperConfigExtend shopperConfigExtend);

    void updateWaimaiItem(WaimaiItem item);

    Map<String,Object> findAllOrders(String appId, String storeName, Integer outSupportId, Integer pageNo, Integer pageSize, List<String> buyerId);

    List<WaimaiExtend> getWaimaiByBuyerIdInUnPaidEffective(String buyerId);
}